using System;
using System.IO;
using System.Xml;
using Anthem;

namespace UsrControls
{
    /// <summary>
    /// Summary description for LabelXml.
    /// </summary>
    public class LabelXml : Label
    {
        public LabelXml()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public string TextXml
        {
            get
            {
                return this.Text;
            }
            set
            {
                if (value != string.Empty)
                {
                    try
                    {
                        StringReader stream = new StringReader(value);
                        XmlTextReader fr = new XmlTextReader(stream);
                        this.Text += "<table border=\"0\" width=\"100%\">";
                        while (fr.Read())
                        {
                            if (fr.NodeType == XmlNodeType.Element && fr.Name != "root")
                            {
                                this.Text += "<tr>";
                                this.Text += "<td vAlign=\"top\" class=\"fila1\" width=\"5%\"><strong>" + fr.Name + ":</strong></td>";
                            }

                            if (fr.HasValue && fr.NodeType == XmlNodeType.Text)
                            {
                                this.Text += "<td vAlign=\"top\" class=\"fila1\" width=\"95%\">" + fr.Value + "</td></tr>";
                            }
                        }
                        this.Text += "</table>";
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException(ex.Message, ex);
                    }
                }

            }

        }
    }
}
